<template>
  <div>
        <!-- 头部面包屑导航 -->
        <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 12px">
            <el-breadcrumb-item :to="{ path: '/wlecome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>数据统计</el-breadcrumb-item>
            <el-breadcrumb-item :to="{path:'/reports'}">数据报表</el-breadcrumb-item>
        </el-breadcrumb>
        
        <!-- 卡片区域 -->
        <el-card>
            <div id="main" style="width: 600px;height:400px;"></div>
        </el-card>
  </div>
</template>

<script>
    import * as echarts from 'echarts';
    import _ from 'lodash'
    export default {
        name: 'DataInfo',
        data () {
            return {
                options: {
                    title: {
                        text: '用户来源'
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#E9EEF3'
                            }
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            boundaryGap: false
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ]
                }  
            }
        },
        methods: {
            

        },
        async mounted () {
            var my_echarts = echarts.init(document.getElementById('main'));
            
            const {data: res_data} = await this.$axios.get('reports/type/1');
            // console.log(res_data);
            // 合并数据 
            var new_config_obj = _.merge(this.options , res_data.data);
            console.log(new_config_obj);
            // 使用数据生成数表
            my_echarts.setOption(new_config_obj);
        }

    }
</script>

<style>
    

</style>
